<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input type="text" placeholder="请输入邮箱" id="email">
    <input type="password" placeholder="请输入密码" id="pwd">
    <script>
        var email = document.getElementById("email")
        email.onkeyup = function(event){
            if(event.keyCode == 13){
                var value = this.value.trim()
                var reg = /^[\w]+@[0-9a-z]+\.[a-z]+$/
                console.log(reg.test(value));
            }
        }
        /* 合法邮箱
          [\w]+@[0-9a-z]+\.[a-z]+
        */

        var pwd = document.getElementById("pwd")
        pwd.onkeyup = function(event){
            if(event.keyCode == 13){
                var value = this.value.trim()
                var reg =/^\d{6}$/
                console.log(reg.test(value));
            }
        }
        /* 密码    /^\d{6}$/    */

        // 账户密码  以字母开头，后面是数字，数字至少包含5位
        //    /^[a-z]+\d{5,}$/
        var str = "Asd21345"
        var reg = /^[A-z]+\d{5,}$/
        console.log(reg.test(str));
    </script>
</body>
</html>